//错误提示动画
function etips(msg) {
	$('.etipsmsg').text(msg)
	$('.errortips').fadeIn('fast');
	setTimeout(function() {
		$('.errortips').fadeOut('fast')
	}, 2000)
}
//正确提示动画
function stips(msg) {
	$('.stipsmsg').text(msg)
	$('.successtips').fadeIn('fast');
	setTimeout(function() {
		$('.successtips').fadeOut('fast')
	}, 2000)
}
var vm = new Vue({
	el: '#app',
	data: {
		dataGoods: [], //获取table数据
		total: '', //数据总条数
		amount: '', //数量
		mprice: '', //金额
		title: '' //修改客户id
	},
	mounted() {
		$('#mloading').modal({
			backdrop: 'static',
			keyboard: false
		}, 'show');
		this.getdata();
	},
	methods: {
		//添加页
		addpagenum() {
			console.log(1)
		},
		getid(e) {
			//			console.log(e);
			this.getdata(e);
		},
		getdata(num) {
			$.ajax({
				type: "get",
				url: "rapData.json",
				async: true,
				data: {

				},
				success: (res) => {
					$('#mloading').modal('hide');
					//			console.log('总数据', e);
					this.dataGoods = res[0].Data;
//					this.total = e.total;
					//			console.log(num)
					$.each(res, (n, n1) => {
						if(n1.pageNum == num) {
							this.dataGoods = n1.Data;
						}
					});
				}
			});
		},

		//					修改
		edit: function(i) {
			var self = this;
			self.amount = self.dataGoods[i].quantity;
			self.mprice = self.dataGoods[i].ttprice;
			self.title = self.dataGoods[i].id;
		},
		//					修改成功提交
		reviseSubmit: function() {
			//						stips('修改成功');
			var self = this;
			$.ajax({
				type: "update",
				url: "xxx/rap/",
				async: true,
				data: {
					id: self.title,
					quantity: self.amount,
					ttprice: self.mprice
				},
				success: function(res) {
					stips('修改成功');
				}
			});
		},
		//					删除
		deleted: function(i) {
			//						etips('删除成功');
			var self = this;
			var id = self.dataGoods[i].id;
			$.ajax({
				type: "delete",
				url: "xxx/rap/",
				async: true,
				data: {
					id: id
				},
				success: function(res) {
					etips('删除成功');
				}
			});
		}
	}
})